//
//  MineCreateOpusTypeItemCell.m
//  ShowYork
//
//  Created by hxh on 2021/3/8.
//  Copyright © 2021 hxh. All rights reserved.
//

#import "MineCreateOpusTypeItemCell.h"

@interface MineCreateOpusTypeItemCell ()
@property (nonatomic,strong)UIButton *coverBtn;
@property (nonatomic,strong)UILabel *coverLb;
@end

@implementation MineCreateOpusTypeItemCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    
    self.coverBtn = [[UIButton alloc]init];
    self.coverBtn.layer.cornerRadius = 13;
    self.coverBtn.layer.borderColor = C102.CGColor;
    self.coverBtn.layer.borderWidth = 1;
    self.coverBtn.layer.masksToBounds = YES;
    [self.contentView addSubview:self.coverBtn];
    
    [self.coverBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
    }];
    
    
    self.coverLb = [[UILabel alloc]init];
    self.coverLb.text = @"测试";
    self.coverLb.textColor = C102;
    self.coverLb.font = font(12);
    [self.contentView addSubview:self.coverLb];
    
    [self.coverLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.coverBtn);
    }];

    [self.coverBtn addTarget:self action:@selector(coverMethod) forControlEvents:UIControlEventTouchUpInside];
    
}

- (void)coverMethod{
    self.itemModel.isSelect =! self.itemModel.isSelect;
    if (self.itemModel.isSelect) {
        self.coverBtn.layer.borderColor = RGBA(245, 75, 100, 1).CGColor;
        self.coverLb.textColor = RGBA(245, 75, 100, 1);
    }else{
        self.coverBtn.layer.borderColor = C102.CGColor;
        self.coverLb.textColor = C102;
    }
    if (self.delegate && [self.delegate respondsToSelector:@selector(updateOpusStautsWithCurrentItem:)]) {
        [self.delegate updateOpusStautsWithCurrentItem:self.itemModel];
    }
}

- (void)setItemModel:(SocialSubTagModel *)itemModel{
    _itemModel = itemModel;
 
    self.coverLb.text = itemModel.tagName;
    
    if (itemModel.isSelect) {
        self.coverBtn.layer.borderColor = RGBA(245, 75, 100, 1).CGColor;
        self.coverLb.textColor = RGBA(245, 75, 100, 1);
    }else{
        self.coverBtn.layer.borderColor = C102.CGColor;
        self.coverLb.textColor = C102;
    }
}

@end
